import request from "@/utils/request"
const BASE_URL = process.env.VUE_APP_BASE_URL

/**
 * 新增或编辑语言包
 * @param {*} data
 */
export function adminLanguagePackSetAPI(data) {
	console.log(data)
	const param = new FormData()
	Object.keys(data).forEach(key => {
		param.append(key, data[key])
	})
	return request({
		url: BASE_URL + "adminLanguagePack/addOrUpdateLanguagePack",
		method: "post",
		data: param,
		headers: {
			"Content-Type": "multipart/form-data"
		}
	})
}

/**
 * 删除语言包
 * @param {*} data
 */
export function adminLanguagePackDeleteAPI(data) {
	return request({
		url: BASE_URL + "adminLanguagePack/deleteLanguagePackById",
		method: "post",
		data: data
	})
}

/**
 * 导出语言包
 * @param {*} data
 */
export function adminLanguagePackExportAPI(data) {
	return request({
		url: BASE_URL + "adminLanguagePack/exportLanguagePackById",
		method: "post",
		data: data,
		responseType: "blob"
	})
}

/**
 * 导出模板
 * @param {*} data
 */
export function adminLanguagePackTemplateAPI(data) {
	return request({
		url: BASE_URL + "adminLanguagePack/downloadExcel",
		method: "post",
		data: data,
		responseType: "blob"
	})
}

/**
 * 查询语言包字段信息
 * @param {*} data
 */
export function adminLanguagePackQueryAPI(data) {
	return request({
		url: BASE_URL + "adminLanguagePack/queryLanguagePackContextById",
		method: "post",
		data: data
	})
}

/**
 * 分页查询语言包列表
 * @param {*} data
 */
export function adminLanguagePackListAPI(data) {
	return request({
		url: BASE_URL + "adminLanguagePack/queryLanguagePackList",
		method: "post",
		data: { ...data, languagePackType: 1 },
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 修改默认语言包配置
 * @param {*} data
 */
export function adminLanguagePackSetDeflautAPI(data) {
	return request({
		url: BASE_URL + "adminLanguagePack/setDeflautLanguagePackSetting",
		method: "post",
		data: data
	})
}

// /**
//  * 查询系统默认语言
//  * @param {*} data
//  */
// export function adminLanguagePackQueryDeflautAPI(data) {
//   return request({
//     url: BASE_URL + 'adminLanguagePack/queryDeflautLanguagePackSetting',
//     method: 'post',
//     data: { ...data, languagePackType: 1 },
//     headers: {
//       'Content-Type': 'application/json;charset=UTF-8'
//     }
//   })
// }

/**
 *  查询用户默认语言info
 * @param {*} data
 */
export function adminUserQueryUserDeflautLanguageInfoAPI(data) {
	return request({
		url: BASE_URL + `/adminUser/queryUserDeflautLanguageInfo`,
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 *  查询系统默认语言info
 * @param {*} data
 */
export function adminLanguagePackQueryDeflautLanguagePackSettingInfoAPI(data) {
	return request({
		url: BASE_URL + `/adminLanguagePack/queryDeflautLanguagePackSettingInfo`,
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}
